# -*- coding: utf-8 -*-


if __name__ == '__main__':
    from generator import Generator
    from comparators import BitCmpCircuit
    from analyzer import Analyzer
    f = open('log.txt','w')
    
    SIZE = range(2,66,2)
    MODIFY = 0
    REDUCE = 0
    
    #SIZE[2] = [1,2,4,8,16,32]
    #SIZE[4] = [1,2,4,8,16]
    #SIZE[8] = [1,2,3] # 4 and more cause can not alocate memory error
    #SIZE[16] = [1,2,3,4]

    #circuit_data = gen.generate(8, 64, DiffComparatorCircuit)
    #circuit_data = gen.generate(2, 16, DiffComparatorCircuit)
    #circuit_data = gen.generate(4, 8, DiffComparatorCircuit)
    for size in SIZE:
        print '======================= NEW ANALYSIS =============================='
        gen = Generator()
        #circuit_data = gen.generateOddEvenSort(size, BitCmpCircuit, MODIFY, REDUCE)
        circuit_data = gen.generateOddEvenMerge(size,BitCmpCircuit)
        gen.modify(circuit_data, size, False)
        #circut = gen.generateOddEvenSort(10,BitCmpCircuit,True,True)

        #print circuit_data
        analyzer = Analyzer(size=size, modify=MODIFY, reduce=REDUCE)
        analyzer.feed(circuit_data)
        analyzer.process()
        #analyzer.createPlot()
        print size
        stats = analyzer.makeStatistics()
        print stats
        f.write(str(size) + ', ' + stats + '\n')
        f.flush()
                
        print '======================= END OF ANALYSIS ===========================\n\n'

    print '======+===+================ JOB DONE ==============================\n\n'
    f.close()
    
    